package com.googlecode.dgwt.client.dojo.data.listener;

import com.googlecode.dgwt.client.dojo.exception.AttachException;

/**
 * Represents an object that is listening to when it is attached on another
 * object.
 * 
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public interface AttachListener<Parent> {

    /**
     * Called before an object add this to it's children
     * 
     * @param parent
     *            the object where this will be attached
     * @throws AttachException
     *             children should throws {@link AttachException} if it cannot
     *             be attached to the parent by any reason
     */
    public void onAttach(Parent parent) throws AttachException;

    /**
     * Called after this object have been detached from the parent
     * 
     * @param parent
     *            object that had this as a child
     */
    public void onDetach(Parent parent);

}
